﻿Imports System.Web.Services
Imports System.ComponentModel
Imports MeoTom.Core

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class MeoTom_Services
    Inherits WebService

    <WebMethod()> _
    Public Function UpdateHomePage(ByVal UserName As String, ByVal Password As String) As String
        If UserName.Equals(Configs.WebSrvUserName) And Password.Equals(Configs.WebSrvPassword) Then
            Dim article As New BLL.Articles()
            Try
                article.WriteRss(1000000)
                article.WriteTopStory()
                article.WriteTop10Last()
                article.WriteTop10View()
                Return "True"
            Catch ex As Exception
                Return "False"
            Finally
                article = Nothing
            End Try
        Else
            Return "Fail To Login"
        End If
    End Function

    <WebMethod()> _
    Public Function UpdateViewByMonth(ByVal UserName As String, ByVal Password As String) As String
        If UserName.Equals(Configs.WebSrvUserName) And Password.Equals(Configs.WebSrvPassword) Then
            Dim article As New BLL.Articles()
            Try
                article.UpdateViewCountMonth()
                Return "True"
            Catch ex As Exception
                Return "False"
            Finally
                article = Nothing
            End Try
        Else
            Return "Fail To Login"
        End If
    End Function

    <WebMethod()> _
    Public Sub SendMail(ByVal iTO As String, ByVal Subject As String, ByVal Body As String, ByVal CC As String)
        Dim mailer As New Utilities.Mail(Configs.SmtpHost, Configs.SmtpUser, Configs.SmtpPass, Configs.WebMasterEmail)
        mailer.Send(iTO, Subject, Body, False, CC)
        mailer = Nothing
    End Sub
End Class